import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { KitModule } from '../kit/kit.module';
import { TemplateModule } from '../template/template.module';
import { LabelsModule } from '../labels/labels.module';
import * as path from 'path';
import { FilesModule } from '../files/files.module';
@Module({
  imports: [
    TypeOrmModule.forRootAsync({
        imports: [ConfigModule],
        inject: [ConfigService],
        useFactory: (configService: ConfigService) => ({
            type: 'mysql',
            host: configService.get('DB_HOST'),
            port: configService.get<number>('DB_PORT'),
            username: configService.get('DB_USERNAME'),
            password: configService.get('DB_PASSWORD'),
            database: configService.get('DB_DATABASE'),
            entities: [path.join(__dirname,'../') + '/**/*.entity{.ts,.js}'],
            synchronize: true,
          }),
      }),
    ConfigModule.forRoot({
        envFilePath: `.env.${process.env.NODE_ENV || 'development'}`
    }),
    FilesModule,
    KitModule,
    TemplateModule,
    LabelsModule
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
